<?php
namespace Mobilerecord\Controller;
use Think\Controller;
class IndexController extends Controller {
    public function index(){
        if(IS_GET){
            $this->display('login');
        }else{

        }

    }

    public function sign(){
        $this->display();
    }

    public function dump(){
        header("Content-type: text/html; charset=utf-8");
        dump($_GET);
        dump($_POST);
    }

    public function uploadify(){
        $ret=array('strings'=>$_POST,'error'=>'0');
        if (!empty($_FILES)) {
            import("@.Think.UploadFile");
            $upload = new \Think\Upload();
            $upload->rootPath  = C('UPLOAD_ROOT_PATH');
            $upload->savePath = C('UPLOAD_SAVE_PATH');
            $upload->autoSub = false;
            $upload->saveRule = uniqid; //上传规则
            $info = $upload->upload();
            if(!$info){
                echo $this->error($upload->getError());//获取失败信息
            } else {
                //成功
                $fileArray = "";
                foreach ($info as $file) {
                    $fileArray = '/upload/' . $file['savepath'] . $file['savename'];
                }
                $fs[0]=array('name'=>trim($fileArray),'url'=>trim($fileArray),'type'=>$file['type'],'size'=>$file['size']);
            }

            $ret['files']=$fs;
//            echo json_encode($ret);
            echo $fileArray;
        }
    }
}